<template>
  <div class="wrap">
    <div class="deleStatus" @click="showmsg = true">
      评论
      <img src="@/assets/deleMsg.png" alt="" class="deleImg" />
    </div>
    <div class="main">
      <div class="titleWrap">
        <div
          class="titleItem"
          :class="{ titleItemActive: whichTitle == 0 }"
          @click="changeTitleOptions(0)"
        >
          评论我的
        </div>
        <div
          class="titleItem"
          :class="{ titleItemActive: whichTitle == 1 }"
          @click="changeTitleOptions(1)"
        >
          我评论的
        </div>
      </div>
      <!-- 评论我的： -->
      <div class="forumList" v-if="whichTitle == 0">
        <div class="forumItem" v-for="(item, index) in fromCommentList" :key="index">
          <div class="itemTop">
            <img
              :src="$imgUrl + item.fromHeadImage"
              alt=""
              class="headPhoto"
              @click="jumpUserInfo"
            />
            <div class="leftWhopraise">
              <div class="name">
                {{ item.fromNickName }} <em class="geryPraise">评论了这条帖子</em>
              </div>
              <div class="time">{{ item.createTime }}</div>
            </div>
            <img
              src="@/assets/point.png"
              alt=""
              class="pointRight"
              @click="replyOptions(item)"
            />
          </div>
          <div class="itemBottom" @click="jumpForumInfo(item.articleId)">
            <div class="whichComment">
              {{ item.fromNickName }}：{{ item.commentContent }}
            </div>
            <div class="whichForum">
              <!-- <img :src="$imgUrl + item.articleImageUrl[0]" alt="" class="forumImg" /> -->
              <div class="rightIntro">
                <div class="whoAt">{{ item.toNickName }}</div>
                <div class="forumTextInfor">
                  <!-- <em class="fontWeight">#故乡的云# </em> -->
                  {{ item.articleContent }}
                </div>
              </div>
            </div>
            <!-- <div class="commentRemark">
              <div class="input">
                <van-field
                  v-model="message"
                  rows="1"
                  autosize
                  type="textarea"
                  placeholder="留下你的精彩评论吧"
                />
              </div>
              <img src="@/assets/emg.png" alt="" class="emg" />
            </div> -->
          </div>
        </div>
        <!-- <div class="forumItem">
          <div class="itemTop">
            <img
              src="@/assets/dele/forum1.png"
              alt=""
              class="headPhoto"
              @click="jumpUserInfo"
            />
            <div class="leftWhopraise">
              <div class="name">山海未眠 <em class="geryPraise">评论了这条帖子</em></div>
              <div class="time">10-05 07:23</div>
            </div>
          </div>
          <div class="itemBottom">
            <div class="whichComment">
              @王二小：回到了故乡，才发现这样的蓝天在大城市太难见到了，新鲜的空气，田野的空旷...我爱这里...
            </div>
            <div class="whichForum whichForum2">
              @王二小 <em class="deleEd">评论已被删除！</em>
            </div>
            <div class="commentRemark">
              <div class="input">
                <van-field
                  v-model="message"
                  rows="1"
                  autosize
                  type="textarea"
                  placeholder="留下你的精彩评论吧"
                />
              </div>
              <img src="@/assets/emg.png" alt="" class="emg" />
            </div>
          </div>
        </div> -->
      </div>
      <!-- 我评论的： -->
      <div class="forumList" v-else>
        <div class="forumItem" v-for="(item, index) in toCommentList" :key="index + 'a'">
          <div class="itemTop">
            <img
              :src="$imgUrl + item.fromHeadImage"
              alt=""
              class="headPhoto"
              @click="jumpUserInfo"
            />
            <div class="leftWhopraise">
              <div class="name">
                {{ item.fromNickName }} <em class="geryPraise">的帖子</em>
              </div>
              <div class="time">{{ item.createTime }}</div>
            </div>
            <!-- <img
              src="@/assets/point.png"
              alt=""
              class="pointRight"
              @click="replyOptions(item)"
            /> -->
          </div>
          <div class="itemBottom" @click="jumpForumInfo(item.articleId)">
            <div class="whichComment">{{ item.nickName }}：{{ item.commentContent }}</div>
            <div class="whichForum">
              <!-- <img :src="$imgUrl + item.articleImageUrl[0]" alt="" class="forumImg" /> -->
              <div class="rightIntro">
                <div class="whoAt">{{ item.fromNickName }}:</div>
                <div class="forumTextInfor">
                  <!-- <em class="fontWeight">#故乡的云# </em> -->
                  {{ item.articleContent }}
                </div>
              </div>
            </div>
            <!-- <div class="commentRemark">
              <div class="input">
                <van-field
                  v-model="message"
                  rows="1"
                  autosize
                  type="textarea"
                  placeholder="留下你的精彩评论吧"
                />
              </div>
              <img src="@/assets/emg.png" alt="" class="emg" />
            </div> -->
          </div>
        </div>
        <!-- <div class="forumItem">
          <div class="itemTop">
            <img
              src="@/assets/dele/forum1.png"
              alt=""
              class="headPhoto"
              @click="jumpUserInfo"
            />
            <div class="leftWhopraise">
              <div class="name">山海未眠 <em class="geryPraise">评论了这条帖子</em></div>
              <div class="time">10-05 07:23</div>
            </div>
          </div>
          <div class="itemBottom">
            <div class="whichComment">
              @王二小：回到了故乡，才发现这样的蓝天在大城市太难见到了，新鲜的空气，田野的空旷...我爱这里...
            </div>
            <div class="whichForum whichForum2">
              @王二小 <em class="deleEd">评论已被删除！</em>
            </div>
            <div class="commentRemark">
              <div class="input">
                <van-field
                  v-model="message"
                  rows="1"
                  autosize
                  type="textarea"
                  placeholder="留下你的精彩评论吧"
                />
              </div>
              <img src="@/assets/emg.png" alt="" class="emg" />
            </div>
          </div>
        </div> -->
      </div>
    </div>

    <!-- 遮罩层-举报 -->
    <div class="maskWrap" v-if="show">
      <div class="maskBg" @click="show = false"></div>
      <div class="chooseNumWrap">
        <div class="optionsItem" @click="jumpReportkinds">举报评论</div>
        <div class="optionsItem dele" @click="show = false">取消</div>
      </div>
    </div>
    <!-- 遮罩层-清空消息： -->
    <div class="maskWrap" v-if="showmsg">
      <div class="maskBg" @click="showmsg = false"></div>
      <div class="chooseNumWrap">
        <div class="optionsItem" @click="getClearMessage(2)">清空评论我的</div>
        <div class="optionsItem" @click="getClearMessage(5)">清空我评论的</div>
        <div class="optionsItem" @click="getClearMessage(7)">清空全部消息</div>
        <div class="optionsItem dele" @click="showmsg = false">取消</div>
      </div>
    </div>
  </div>
</template>

<script>
import { Field } from "vant";
import {
  apiCommentRecordList,
  apiCommentMessageList,
  apiClearMessage,
} from "@/request/api"; // api接口
export default {
  name: "App",
  data() {
    return {
      message: "",
      show: false,
      showmsg: false,
      toCommentList: [], //我的评论列表
      fromCommentList: [], //评论我的列表
      whichTitle: 0, //0-评论我的，1-我评论的
      willJumpData: "", //即将跳转携带的数据
    };
  },
  mounted() {
    document.querySelector("body").setAttribute("style", "background-color:#F2F4FA");
    this.getCommentRecordList();
    this.getCommentMessageList();
  },
  methods: {
    changeTitleOptions(num) {
      this.whichTitle = num;
    },
    //获取我的评论消息列表:
    getCommentRecordList() {
      apiCommentRecordList({}).then((res) => {
        var dataRes = res.data;
        console.log("dataRes我的", dataRes);
        // if(res.data.length==0){
        //   console.log('return')
        //   this.toCommentList = res.dataRes
        //   return
        // }
        dataRes.map((item) => {
          item.articleImageUrl = item.articleImageUrl.split(",");
        });
        this.toCommentList.push(...dataRes);
        console.log("我的", this.toCommentList);
      });
    },
    //获取评论我的消息列表:
    getCommentMessageList() {
      apiCommentMessageList({}).then((res) => {
        var dataRes = res.data;
        console.log("dataRes别人", dataRes);
        if (res.data.length == 0) {
          console.log("return00");
          this.fromCommentList = res.dataRes;
          return;
        }
        // dataRes.map((item) => {
        //   console.log('item.articleImageUr',item.articleImageUrl)
        //   item.articleImageUrl = item.articleImageUrl.split(",");
        // });
        this.fromCommentList.push(...dataRes);
        console.log("别人的", this.fromCommentList);
      });
    },
    isContains(str, substr) {
      return new RegExp(substr).test(str);
    },
    //点击point：
    replyOptions(data) {
      this.show = true;
      this.willJumpData = data;
    },
    //举报评论
    jumpReportkinds() {
      let obj ={
          dataJump: this.willJumpData,
          contentType: 1, //评论类型：1
       }
      this.$store.commit('reportPara',obj)
      this.$router.push({
        path: "/pages/reportkinds",
        query: obj,
      });
    },
    //清空消息的操作：
    getClearMessage(i) {
      apiClearMessage({
        msgType: i,
      }).then((res) => {
        if (res.code == 200) {
          this.showmsg = false;
          this.getCommentRecordList();
          this.getCommentMessageList();
          this.$toast.success("已清空");
        }
      });
    },
    jumpForumInfo(id) {
      this.$router.push({
        path: "/pages/forumInfo",
        query: {
          //传递参数
          forumId: id,
        },
      });
    },
    jumpUserInfo() {
      this.$router.push({
        path: "/pages/forumPersonalCenter",
        query: {
          //传递参数
        },
      });
    },
  },
  created() {},
  components: {
    [Field.name]: Field,
  },
};
</script>

<style scoped>
.deleStatus {
  font-size: 16px;
  font-weight: 500;
  color: #181818;
  text-align: center;
  height: 50px;
  line-height: 50px;
}
.deleImg {
  width: 13px;
  height: 13px;
}
.main {
  width: 95%;
  margin: 0 auto;
}
.titleWrap {
  width: 90%;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
}
.titleItem {
  width: 105px;
  height: 37px;
  line-height: 37px;
  text-align: center;
  border-radius: 19px;
  font-size: 14px;
  font-weight: 400;
  color: #666666;
}
.titleItemActive {
  background: #181818;
  color: #fff;
}
.forumList {
}
.forumItem {
}
.itemTop {
  overflow: hidden;
  margin-top: 25px;
}
.headPhoto {
  float: left;
  height: 40px;
  width: 40px;
  border-radius: 40px;
  float: left;
}
.leftWhopraise {
  float: left;
  margin-left: 10px;
}
.pointRight {
  float: right;
  width: 13px;
  height: 3px;
  margin-top: 5px;
  margin-right: 15px;
}
.name {
  font-size: 14px;
  font-weight: 400;
  color: #181818;
}
.geryPraise {
  font-size: 14px;
  font-weight: 400;
  color: #666666;
}
.time {
  font-size: 11px;
  font-weight: 300;
  color: #999999;
  margin-top: 5px;
}
.itemBottom {
  background: #ffffff;
  border-radius: 20px;
}
.itemBottom2 {
  padding-top: 15px;
  margin-top: 15px;
}
.whichComment {
  font-size: 13px;
  font-weight: 400;
  color: #181818;
  margin: 14px 16px;
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e5e5e5;
}
.whichForum {
  overflow: hidden;
  padding-bottom: 20px;
}
.whichForum1 {
  margin-left: 20px;
}
.whichForum2 {
  padding-left: 20px;
  font-size: 13px;
  color: #181818;
}
.deleEd {
  font-weight: 600;
}
.attention2 {
  font-size: 10px;
  font-weight: 500;
  color: #ffffff !important;
  background-color: #b5b3b2 !important;
  float: right;
  margin-right: 20px;
}
.forumImg {
  float: left;
  width: 88px;
  height: 102px;
  margin-left: 14px;
  margin-bottom: 16px;
}
.rightIntro {
  width: calc(100% - 127px);
  float: left;
  margin-left: 15px;
  font-size: 11px;
  font-weight: 500;
  color: #181818;
}
.whoAt {
  font-size: 13px;
  font-weight: 400;
  margin: 15px 0px 13px 0px;
}
.name {
}
.time {
  padding-left: 5px;
}
.attention {
  display: inline-block;
  height: 23px;
  line-height: 23px;
  text-align: center;
  background: #181818;
  border-radius: 12px;
  color: #fff;
  font-size: 10px;
  padding: 0px 10px;
  margin-left: 30px;
}
.forumTextInfor {
}
.praiseOptions {
  overflow: hidden;
  margin-top: 15px;
  margin-bottom: 15px;
  width: 170px;
  float: right;
}
.praiseItem {
  float: left;
  margin: 0px 10px;
}
.optionsCount {
}
.optionsImg {
  width: 13px;
  height: 11px;
}
.optionsImg1 {
  width: 12px;
  height: 11px;
}
.optionsImg2 {
  width: 13px;
  height: 3px;
  padding-bottom: 3px;
}
.fontWeight {
  font-weight: 600;
}
.maskWrap {
}
.maskBg {
  width: 100%;
  min-height: 100vh;
  opacity: 0.35;
  background-color: #000;
  position: fixed;
  top: 0px;
}
.chooseNumWrap {
  width: 100%;
  background-color: #fff;
  position: fixed;
  bottom: 0px;
  border-radius: 20px 20px 0px 0px;
}
.optionsItem {
  height: 50px;
  line-height: 50px;
  border-bottom: 1px solid #eee;
  color: #000;
  font-size: 14px;
  text-align: center;
}
.dele {
  background-color: #eee;
  border-radius: 20px;
  width: 90%;
  margin: 5px auto;
  height: 40px;
  line-height: 40px;
}
.commentRemark {
  width: 100%;
  overflow: hidden;
}
.input {
  float: left;
  border-radius: 20px;
  width: 70%;
  margin: 15px 20px;
}
.van-cell {
  height: 37px;
  line-height: 20px;
  border-radius: 20px;
  background-color: #1a1c20;
}
.emg {
  float: left;
  width: 18px;
  height: 18px;
  margin-left: 16px;
  margin-top: 25px;
}
</style>
